<?php
	require("./conn.php");
	$username = $_POST['username2'];
	$password = md5($_POST['password2']);
	$password2 = $_POST['password2'];
	$repassword = $_POST['repassword2'];
	$email = $_POST['email'];
	$realname = $_POST['realname'];
	$sql = "select * from app_user where username = '$username'";
	$result = mysql_query($sql);
	$num = mysql_num_rows($result);
	if($num){
		setcookie("status", "no");
		header("Location:index.php?contect=该用户名已存在");
	}else if($password2 != $repassword){
		setcookie("status", "no");
		header("Location:index.php?contect=两次密码不一致");
	}else{
		$sql1 = "insert into app_user(username,password,email,realname)values('$username','$password','$email','$realname')";
		$result1 = mysql_query($sql1);
		setcookie("status", "logout");
		header("Location:index.php?contect=注册成功");
	}
?>